package controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import pojo.WlUser;
import service.WlUserService;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Controller
public class WlUserController {
    @Resource(name="wlUserService")
    WlUserService wlUserService;

    public WlUserService getWlUserService() {
        return wlUserService;
    }

    public void setWlUserService(WlUserService wlUserService) {
        this.wlUserService = wlUserService;
    }
    @RequestMapping("/selectByPage")
    public String selectByPage(HttpServletRequest request,Integer index){
            System.out.print("asssssssssssssssssssssssss");
            index=1;

        int size=wlUserService.count();
        System.out.print(size);
        size=size%10==0?size/10:size/10+1;
        if(index>size){
            index=size;
        }
        int newindex=(index-1)*10;
        List<WlUser> list=wlUserService.selectAll(newindex);
        request.getSession().setAttribute("users",list);
        request.getSession().setAttribute("index",index);
        request.getSession().setAttribute("size",size);
        return "/table_data_tables.jsp";
    }
}
